import request from '@/utils/request'
import type { ApiResponse } from '../index'
import type { Post, PostResponse } from '@/types/post'

interface CreatePostParams {
  title: string
  coverImage: string
  content: string
  city: string
  category: string
}

export const userPostApi = {
  // 获取我的文章列表
  getMyPosts(params?: { page?: number; size?: number; sort?: string[] }) {
    return request.get<ApiResponse<PostResponse['data']>>('/user/posts/my', { params })
  },
  
  // 创建文章
  create(data: CreatePostParams) {
    return request.post<ApiResponse<Post>>('/user/posts', data)
  },
  
  // 更新文章
  update(id: number, data: Partial<CreatePostParams>) {
    return request.put<ApiResponse<Post>>(`/user/posts/${id}`, data)
  },
  
  // 删除文章
  delete(id: number) {
    return request.delete<ApiResponse>(`/user/posts/${id}`)
  }
} 